import { defHttp } from '/@/utils/http/axios';
import { ErrorMessageMode } from '/#/axios';
enum Api {
  GetTable = '/table',
  UnloadFileTemple = '/table/upload-tpl-file',
  EditStatus = '/table/status',
  ImportTableData = '/table/data/import',
  DeleteTableData = '/table/data/batch-delete',
  GetTableList = '/table/data/list',
  GetTableData = '/table/data',
  GetTabList = '/table/list',
  Statsitic = '/procurement-internal/statsitic/new',
}

// 获取表格列表
export function getTable(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.GetTable, params },
    {
      errorMessageMode: mode,
    },
  );
}
// 获取表格列表
export function getTab(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.GetTabList, params },
    {
      errorMessageMode: mode,
    },
  );
}
// 获取表格详情
export function getTableInfo(id: any, mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.GetTable + `/${id}` },
    {
      errorMessageMode: mode,
    },
  );
}
// 删除表格
export function delTable(id: any, mode: ErrorMessageMode = 'message') {
  return defHttp.delete(
    { url: Api.GetTable + `/${id}` },
    {
      errorMessageMode: mode,
    },
  );
}
// 保存
export function saveTable(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.post(
    { url: Api.GetTable, params },
    {
      errorMessageMode: mode,
    },
  );
}
// 上传模板文件
export function unloadFileTemple(mode: ErrorMessageMode = 'message') {
  return defHttp.post(
    { url: Api.UnloadFileTemple },
    {
      errorMessageMode: mode,
    },
  );
}
// 修改表格状态
export function editStatus(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.post(
    { url: Api.EditStatus, params },
    {
      errorMessageMode: mode,
    },
  );
}
// 导入表格数据
export function importTableData(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.post(
    { url: Api.ImportTableData, params },
    {
      errorMessageMode: mode,
    },
  );
}
// 批量删除表格数据
export function deleteTableData(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.post(
    { url: Api.DeleteTableData, params },
    {
      errorMessageMode: mode,
    },
  );
}
// 查询表格信息
export function getTableList(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.post(
    { url: Api.GetTableList, params },
    {
      errorMessageMode: mode,
    },
  );
}
// 获取表格数据列表
export function getTableData(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.GetTableData, params },
    {
      errorMessageMode: mode,
    },
  );
}
// 价格对比分析
export function statsitic(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.Statsitic, params },
    {
      errorMessageMode: mode,
    },
  );
}
